<template>
  <div>
    <el-form
      :inline="true"
      :model="searchPostVo"
      class="demo-form-inline"
      style="margin-top: 25px; margin-left: 30%"
    >
      <el-form-item label="帖子所属模块">
        <el-select
          v-model="searchPostVo.pBoardId"
          placeholder="请选择活动区域"
          @change="changePBoardId"
        >
          <el-option label="话题广场" value="0"></el-option>
          <el-option label="教师资源分享" value="1"></el-option>
          <el-option label="新生可了解" value="2"></el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="帖子所带话题" v-if="searchPostVo.pBoardId === '0'">
        <el-input
          v-model="searchPostVo.tag"
          placeholder="请输入帖子话题"
        ></el-input>
      </el-form-item>
      <el-form-item label="所属科目" v-if="searchPostVo.pBoardId === '1'">
        <el-input
          v-model="searchPostVo.tag"
          placeholder="请输入帖子科目"
        ></el-input>
      </el-form-item>
      <el-form-item label="所属栏目" v-if="searchPostVo.pBoardId === '2'">
        <el-select v-model="searchPostVo.tag" placeholder="请选择所属栏目">
          <el-option label="通知" value="通知"></el-option>
          <el-option label="入学指南" value="入学指南"></el-option>
          <el-option label="日常生活" value="日常生活"></el-option>
          <el-option label="学业疑难" value="学业疑难"></el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item>
        <el-button
          type="primary"
          @click="getAllTipOff(1, searchPostVo.pBoardId, currentPage, limit)"
          >查询</el-button
        >
      </el-form-item>
    </el-form>
    <el-table :data="articleList" border style="width: 100%">
      <el-table-column
        prop="pboardName"
        label="帖子所属板块"
        width="125"
        align="center"
      >
      </el-table-column>
      <el-table-column prop="tag" label="帖子类别" width="100" align="center">
      </el-table-column>

      <el-table-column
        prop="nickName"
        label="发帖人昵称"
        width="100"
        align="center"
      >
      </el-table-column>
      <el-table-column label="标题" width="300" align="center">
        <template slot-scope="scope">
          <P>
            {{ scope.row.title }}
          </P>
        </template>
      </el-table-column>
      <el-table-column
        prop="userNickName"
        label="举报人昵称"
        width="150"
        align="center"
      >
      </el-table-column>
      <el-table-column label="举报原因" width="200" align="center">
        <template slot-scope="scope">
          <div class="multiple-overflow">
            {{ scope.row.desc }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="400" align="center">
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="mini"
            icon="el-icon-more"
            @click="checkDetails(scope.row.desc)"
            >举报详情</el-button
          >

          <el-button
            type="success"
            size="mini"
            icon="el-icon-delete"
            @click="ignoreTipOff(scope.row.tipoffId, scope.row.userId, 1)"
            >忽略举报</el-button
          >
          <el-button
            type="danger"
            size="mini"
            icon="el-icon-delete"
            @click="withdrawArticle(scope.row.articleId)"
            >撤回文章</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :current-page="currentPage"
      :total="totalRecords"
      :page-size="limit"
      :page-sizes="[5, 10, 15, 20, 25, 30, 35]"
      style="margin: 30px 0; text-align: center"
      layout="sizes,prev,pager,next,jumper,->,total,slot"
      @current-change="getStudentList"
      @size-change="changeSize"
    />
  </div>
</template>

<script>
import adminControll from "@/api/adminControll";
export default {
  data() {
    return {
      searchPostVo: {
        pBoardId: "",
        tag: "",
      },
      currentPage: 1,
      limit: 5,
      totalRecords: 100,
      articleList: [
        {
          tipoffId: 0,
          articleId: "",
          pBoardName: "话题广场",
          tag: "通知",
          nickName: "Xzh",
          title: "新版的射雕英雄传《金庸武侠世界》",
          userNickName: "Mike",
          desc: "该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
        {
          tipoffId: 0,
          articleId: "",
          pBoardName: "话题广场",
          tag: "通知",
          nickName: "Xzh",
          title: "新版的射雕英雄传《金庸武侠世界》",
          userNickName: "Mike",
          desc: "该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
        {
          tipoffId: 0,
          articleId: "",
          pBoardName: "话题广场",
          tag: "通知",
          nickName: "Xzh",
          title: "新版的射雕英雄传《金庸武侠世界》",
          userNickName: "Mike",
          desc: "该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
        {
          tipoffId: 0,
          articleId: "",
          pBoardName: "话题广场",
          tag: "通知",
          nickName: "Xzh",
          title: "新版的射雕英雄传《金庸武侠世界》",
          userNickName: "Mike",
          desc: "该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
        {
          tipoffId: 0,
          articleId: "",
          pBoardName: "话题广场",
          tag: "通知",
          nickName: "Xzh",
          title: "新版的射雕英雄传《金庸武侠世界》",
          userNickName: "Mike",
          desc: "该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
      ],
    };
  },

  components: {},

  computed: {},

  created() {
    this.searchPostVo.pBoardId = 0;
    this.getAllTipOff(
      1,
      this.searchPostVo.pBoardId,
      this.currentPage,
      this.limit
    );
  },

  methods: {
    changeSize(size) {
      this.limit = size;
      this.getStudentList(1);
    },
    getStudentList(page = 1) {},
    changePBoardId(value) {
      console.log(value);
    },
    checkDetails(desc) {
      this.$alert(desc, "举报描述详情", {
        confirmButtonText: "取消",
      });
    },
    ignoreTipOff(tipoffId, informedUserId, type) {
      this.$alert("您确定忽略该举报吗", "举报详情", {
        confirmButtonText: "确定",
        callback: (action) => {
          if (action == "confirm") {
            this.ignore(tipoffId, informedUserId, type);
          }
        },
      });
    },
    ignore(tipoffId, informedUserId, type) {
      adminControll
        .ignoreTipOff(tipoffId, informedUserId, type)
        .then((response) => {
          adminControll
            .getAllTipOff(type, searchType, pageNo, pageSize)
            .then((response) => {
              this.articleList = response.data.records;
              this.totalRecords = response.data.total;
            });
        });
    },
    //撤回文章
    withdrawArticle(articleId) {
      this.$alert("您确定撤回该文章吗", "撤回详情", {
        confirmButtonText: "确定",
        callback: (action) => {
          if (action == "confirm") {
            this.deleteByArticleId(articleId);
          }
        },
      });
    },
    deleteByArticleId(articleId) {
      adminControll.deleteByArticleId(articleId).then((response) => {
        this.selectBoardEssayByTag();
      });
    },
    getAllTipOff(type, searchType, pageNo, pageSize) {
      adminControll
        .getAllTipOff(type, searchType, pageNo, pageSize)
        .then((response) => {
          this.articleList = response.data.records;
          this.totalRecords = response.data.total;
        });
    },
  },
};
</script>
<style scoped>
img {
  display: block;
  width: 75px;
  height: 75px;
}
.exceed {
  color: red;
}
/* 单行溢出处理 */
p {
  width: 250px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.multiple-overflow {
  width: 175px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
</style>
